<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>第一联</title>
</head>
<body>
<div id="contentIdTwoBom" style="width: 900px;height:660px;margin: 5px auto" >
	<table id="twoBom_table"></table>
</div>

<script th:inline="none" type="text/javascript">
	var twoBomTableTwoIndex=1;//没有此变量会死循环(不是循环访问加载后台数据);
	$(function () {
		var codeValue=threeBOMSearchInputCode.textbox("getText");
		var pkOrgValue=threeBOMSearchInputPkOrg.combobox('getValue');
		var twoBomTable=$("#twoBom_table").datagrid({
			//fitColumns:true,
			nowrap:false,
			url:'/reportForms/selectTwoForm?pkOrg='+pkOrgValue+'&code='+codeValue,
			onLoadSuccess:function(data) {
				if (twoBomTableTwoIndex==1){
					twoBomTableTwoIndex++;
					var currentdate=getCurrentDate();
					var materialCode=data.rows[0].materialCode;
					var isProduce=data.rows[0].isProduce;
					var materialName=data.rows[0].materialName;
					var version=data.rows[0].version;
					var formulaNo=data.rows[0].formulaNo;
					twoBomTable.datagrid({
						columns:[
							[
								{ field:'a',title:'Opal Cosmetics (Huizhou) Limited',colspan:5,align:'center'},
							],

							[
								{ field:'proCode1',title:'物料编码',width:100, align:'center',},
								{ field:'proC1',title:materialCode,align:'left',colspan:2,width:100},
								{ field:'d',title:'打印日期：',align:'center'},
								{ field:'e',title:currentdate,align:'center'},
							],
							[
								{ field:'f',title:'物料名称',align:'center',width:100},
								{ field:'g',title:materialName,align:'left',colspan:4},
							],
							[
								{ field:'h',title:'是否可生产:',align:'center',width:100},
								{ field:'i',title:isProduce,align:'center'},
								{ field:'j',title:'工艺版本号:'+version,align:'left',colspan:2,width:100},
								{ field:'l',title:'配方号:'+formulaNo,align:'left'}
							],

							[
								{ field:'vprocessno',title:'Step步骤',align:'center',width:110,},
								{ field:'vcraftnote',title:'Operate instruction\\操作说明'+'<hr/>Item原料编码',align:'center',width:300,
									formatter: function(value,row,index){
										if(row.materialInfo){
											return value+'<hr style="border: 2px"/><hr/><br/>'+row.materialInfo;
										}
										return value+"<hr/><br/><br/>";
									}

								},
								{ field:'note',title:'Record记录',align:'center',width:250},
								{ field:'a1',title:'签名',align:'center',width:118},
								{ field:'b',title:'QC Check 检验',align:'center',width:120},
							],

						],toolbar: [{
							text:'打印',
							iconCls: 'icon-print',
							handler: function(){
								printTwoBom('contentIdTwoBom');
							}

						}]
					})
				}
			},
		});
	});

	function printTwoBom(content){
		//1、获取需要打印的元素HTML

		var printHtml = document.getElementById(content).innerHTML;//这个元素的样式需要用内联方式，不然在新开打印对话框中没有样式

		//2、打开一个窗口，且内容设置为空

		var wind = window.open("",'newwindow', 'height=300, width=700, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no');

		//3、将新窗口内容填充为需要打印的HTML

		wind.document.body.innerHTML = printHtml;

		//4、执行打印操作

		wind.print();
	}
</script>
</body>
</html>